package org.example.consumer.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MyMessageListener {
    /**
     * 普通模式
     */
    @RabbitListener(queues = {"test.queue.simple"})
    public void processMessage(String messageContent, Message message, Channel channel) {
        System.out.println("messageContent = " + messageContent);
    }

    /**
     * 路由模式
     */
    @RabbitListener(queues = {"test.queue.direct"})
    public void processMessageRout(String messageContent, Message message, Channel channel) {
        System.out.println("Rout messageContent = " + messageContent);
    }

    /**
     * Topic模式
     */
    @RabbitListener(queues = {"test.queue.message"})
    public void processMessageTopic01(String messageContent, Message message, Channel channel) {
        System.out.println("Queue Message:" + messageContent);
    }

    /**
     * Topic模式
     */
    @RabbitListener(queues = {"test.queue.order"})
    public void processMessageTopic02(String messageContent, Message message, Channel channel) {
        System.out.println("Queue Order:" + messageContent);
    }
}
